1. Field of the Invention
The present invention relates to a system and method for preventing an input of variable length codes from being interrupted. In particular, the present invention relates to a system and method for preventing an input of variable length codes of an MPEG (Motion Picture Experts Group) signal from being interrupted.
2. Description of the Related Art
An MPEG signal contains a video variable length code and an audio variable length code. The video variable length code is obtained by compressing a video signal corresponding to motion compensated bi-directional inter-frame prediction encoding system using discrete cosine transforming system. The audio variable length code is obtained by compressing an audio signal corresponding to sub-band encoding system. An MPEG signal is used to highly efficiently transmit audio and video signals. In addition, an MPEG signal is used to record audio and video signals to a record medium such as a DVD (Digital Versatile Disc) or a hard drive.
Since an MPEG signal is a digital signal, even if it is copied, the quality thereof is not deteriorated. Thus, when an MPEG signal is illegally copied, the copyright of the content producer is infringed.
To solve such a problem, a technology for inserting an electronic watermark that represents a copyright into DCT (Discrete Cosine Transform) coefficient codes of an MPEG signal that is recorded on a record medium such as a DVD has been developed. In addition, a technology for inserting an electronic watermark for controlling a copying operation into DCT coefficient codes of an MPEG signal that is recorded on a record medium such as a DVD has been developed. In particular, as one type of an electronic watermark for controlling a copying operation, an electronic watermark that does not vary the code amount has been developed. Such an electronic watermark has been used by a content producer. A circuit that detects such an electronic watermark is disposed in a DVD player or a DVD recorder. In the case that such an electronic watermark represents that a copying operation is prohibited, when an MPEG signal into which such an electronic watermark has been inserted is tried to be copied from one DVD to another DVD, the MPEG signal cannot be copied. Thus, the copyright of the content producer can be protected.
When an MPEG signal is copied from one DVD to another DVD, it is preferred to perform it at high speed without need to output a sound and a picture to a speaker and a monitor from a view point of high efficiency. Thus, when an MPEG signal is copied from one DVD to another DVD, a DVD reproducing drive (not DVD player) that reproduces an MPEG signal at a speed several times (or more times) higher than the regular reproducing speed and a DVD recording drive (not DVD player) that records an MPEG signal at a speed several times (or more times) higher than the regular recording speed.
However, to prevent an MPEG signal from being illegally copied, although the DVD drive does not need to provide an MPEG decoding device, the DVD drive should be equipped with a function for decoding a reproduced MPEG signal to DCT coefficients and detecting an electronic watermark from the obtained DCT coefficients.
As an example of related art, FIG. 1 is a block diagram showing a circuit that decodes an MPEG signal to DCT coefficients and detects an electronic watermark from the obtained DCT coefficients.
Referring to FIG. 1, the circuit has an input interface 901, a buffer 902, a video elementary stream extracting circuit 903, a barrel shifter 904, a variable length decoding device 905, a controlling portion 906, an inverse quantizing device 907, and an electronic watermark detecting device 908.
The input interface 901 and an input side of the buffer 902 is driven by an external interface clock that also drives an output interface of a pre-stage portion (not shown). An output side of the buffer 902 and circuits downstream thereof are driven by an internal clock that does not synchronize with the external interface clock.
In addition to an MPEG signal reproducing device such as a DVD reproducing drive, the electronic watermark detecting circuit may be built in an MPEG signal recording device such as a DVD recording drive or an interface device disposed between an MPEG signal reproducing device and an MPEG signal recording device. When an electronic watermark detecting circuit is built in an MPEG signal reproducing device, the pre-stage portion contains a mechanism of an MPEG signal reproducing device, a reproducing mechanism system such as a servo, and a reproduction signal processing system such as a digital signal decoding operation and an error correcting process. When an electronic watermark detecting circuit is built in an MPEG signal recording device or an interface device, the pre-stage portion is for example an MPEG signal reproducing device or a video server connected through a network.
The input interface 901 inputs an eight-bit wide transport stream or eight-bit wide program stream that synchronizes with the external interface clock of the pre-stage portion (hereinafter, both the streams are generally referred to as xe2x80x9cstreamxe2x80x9d). The stream is output to the buffer 902.
The buffer 902 has a clock changing function that causes a stream that synchronizes with an external interface clock to synchronize with an internal clock. In addition, the buffer 902 has a function for absorbing the discontinuity of a stream supplied to the barrel shifter 904, the discontinuity taking place due to the fluctuation of the length of the code decoded by the variable length decoding device 905. For example, the buffer 902 is composed of a FIFO (First-In First-Out). As a write clock for the FIFO memory, the external interface clock is used. As a read clock for the FIFO memory, the internal clock is used. Of course, the write clock of the FIFO memory may synchronize with the read clock thereof. However, generally, the write clock of the FIFO memory does not synchronize with the read clock thereof.
The video elementary stream extracting circuit 903 has a function for extracting a video elementary stream from the input stream. The video elementary stream extracting circuit 903 delays the input stream by the number of clock pulses required to detect the video elementary stream and outputs the resultant frame and a valid flag that represents that each byte of the output stream is contained in the video elementary stream. The video elementary stream extracting circuit 903 is disclosed in for example Japanese Patent Laid-Open Publication No. 2001-345769.
The video elementary stream is a stream placed in a payload of a video PES (Packetized Elementary Stream) (the payload is a remaining portion of a video PES after a PES header is removed therefrom). The video elementary stream is defined in ISO 13818-1.
The barrel shifter 904 is driven by the internal clock whose clock frequency is approximately twice as high as the external interface clock (hereinafter, the internal clock is referred to as two-multiple clock). The barrel shifter 904 continuously inputs an eight-bit wide stream and outputs a stream having a width of 1 to 32 effective bits. Next, the operation of the barrel shifter 904 will be described in detail. The barrel shifter 904 shifts out bits (or proximately decoded bits) designated by the controlling portion 906 from an output shift register of 32-bit width at each two-multiple clock pulse. An output of each register of the output shift register is also supplied to the variable length decoding device 905. When those bits are shifted out, bits that reside in the output shift register are shifted to the beginning portion by bits that have been shifted out. Insufficient bits at the end portion of the output shift register are compensated with each bit of a bit group of the stream that is intermittently input in a unit of byte. After a variable length code is decoded, all bits of at most 32-bit variable length code are arranged in the output shift register. Alternatively, to perform a high speed process, the barrel shifter 904 may be composed of a regular register group and a switch group instead of the output shift register.
Unlike a conventional barrel shifter, the barrel shifter 904 does not input a byte corresponding to a valid flag of which the value represents that the byte is not contained in the video elementary stream. Thus, the barrel shifter inputs only the video elementary stream. By the way, the barrel shifter 904 may be driven by an internal clock other than the two-multiple frequency. For example, the barrel shifter 904 may be driven by an internal clock whose frequency is 1.5 times or 1.9 times higher than the frequency of the external interface clock.
The variable length decoding device 905 decodes a variable length code contained in an output of the barrel shifter 904 in each code unit. The variable length decoding device 905 decodes not only a variable length code for DCT coefficients, but all codes of the video elementary stream containing codes of a sequence header layer, a picture header layer, a slice layer, and a macro block layer and outputs DCT coefficients of the decoded data to the inverse quantizing device 907. The variable length decoding device 905 outputs an error flag that represents whether or not data has been successfully decoded. When the data has been decoded, the variable length decoding device 905 outputs the code length of the decoded code to the controlling portion 906.
The controlling portion 906 outputs the number of bits to be shifted out from the barrel shifter 904 corresponding to the code length that is input from the variable length decoding device 905 to the barrel shifter 904. In addition, the controlling portion 906 controls the decoding operation of the video elementary stream. When the variable length decoding device 905 cannot decode the data due to an occurrence of an error, the variable length decoding device 905 causes the error flag to be active. The variable length decoding device 905 causes the barrel shifter 904 to shift out data with eight bits at a time (byte aligned) so as to decode a byte aligned code (a code that begins at a byte boundary) at a refresh position (at which an error is prevented from propagating) of a slice header code, a picture header code, a sequence header code, or the like. Thus, even if the variable length decoding device 905 cannot decode a variable length code to DCT coefficients due to an occurrence of an error, the variable length decoding device 905 can resume the decoding operation from a refresh position of a byte align code of a slice header code, a picture header code, a sequence code header, or the like.
The controlling portion 906 has a function for calculating a process unit (that is an output unit of the barrel shifter 904) starting from a sequence header code to a decoding operation for DCT coefficients, analyzing the data structure of a video elementary stream starting from a sequence header code to DCT coefficients corresponding to a predetermined parameter stored in the controlling portion 906, and detecting a structure error.
The inverse quantizing device 907 calculates DCT coefficients of each DCT block corresponding to a pair of a zero run and a level, Q_Table and Q_Scale that are input from the variable length decoding device 905. When Q_Table has been set in Quantum_Matrix_Extension of the sequence header layer or the picture header layer, Q_Table is used for calculating DCT coefficients. When Q_Table has not been set, the initial value of Q_Table defined in the MPEG specification is used to calculate DCT coefficients. Q_Scale is obtained by using a table defined in the MPEG specifications corresponding to Q_Scale_Type and Q_Scale_Code. The controlling portion 906 has the table. Q_Scale_Type is contained in Picture_Coding_Extension of the picture layer. Q_Scale_Code is contained in the slice layer and the macro block layer.
The electronic watermark detecting device 908 detects an electronic watermark from DCT coefficients that are input from the inverse quantizing device 907. As a method for detecting an electronic watermark by the electronic watermark detecting device 908, a technology disclosed in for example Japanese Patent Laid-Open Publication No. 2000-138818 or Japanese Patent No. 3109575 (Japanese Patent Laid-Open Publication No. 10-155151) is used.
The input interface 901 does a handshake with the buffer 902 using an output request signal that the input interface 901 outputs to the buffer 902 and an input permission signal that the buffer 902 outputs to the input interface 901. Likewise, the pre-stage portion does a handshake with the input interface 901. The buffer 902 does a handshake with the video elementary stream extracting circuit 903. The video elementary stream extracting circuit 903 does a handshake with the barrel shifter 904. The barrel shifter 904 does a handshake with the variable length decoding device 905. The variable length decoding device 905 does a handshake with the inverse quantizing device 907. According to a handshake, when the post-stage circuit is not ready for inputting a signal, the pre-stage circuit temporarily stops outputting a signal.
The code length of an MPEG signal is in the range from 2 bits to 31 bits. The code length of a DCT coefficient of a MPEG signal is in the range from 2 bits to 24 bits. Thus, depending on a picture, codes of 4 bits or less each may statistically continue. An input stream is input with a width of eight bits and a barrel shifter is driven by a two-multiple clock. Therefore, when codes whose average code length is four bits continue, the amount of codes stored in the buffer 902 slightly varies around a constant value. In contrast, when codes whose average code length is less than four bits continue, the amount of codes stored in the buffer 902 continuously increases. In other words, when codes whose code length is less than four bits each continue, the occupation rate of a variable length code in the buffer 902 increases. Thus, to prevent the buffer 902 from overflowing, (1) the storage capacity of the buffer 902 shall be increased, (2) the input interface 901 shall do a handshake with the buffer 902 and also the pre-stage portion shall do a handshake with the interface 901 so as to temporarily stop the stream supplied from the pre-stage portion to the input interface, or (3) the frequency of the drive clock of the barrel shifter shall be raised.
However, when the storage capacity of the buffer 902 is increased, the circuit scale becomes large. As a result the cost of the device rises. In addition, to temporarily stop the stream supplied from the pre-stage portion to the input interface, the corresponding function should be disposed in the pre-stage portion. Thus, an additional circuit, an additional mechanism, or the like is required. As a result, the cost of the device rises. In addition, when the frequency of the drive clock of the barrel shifter is raised, it becomes difficult to design the timings of the barrel shifter and the peripheral circuits. In addition, the circuit scale becomes large. As a result, the cost of the device rises.
The prevent invention is made from the foregoing point of view. An object of the present invention is to provide a system and method for preventing an input of variable length codes from being interrupted even if short length codes continue without need to increase the circuit scale.
When a moving picture is reproduced from an MPEG signal, it is desired to obtain as much video information and audio information as possible from the MPEG signal from a view point of high quality. Thus, when a moving picture is reproduced, an error correction, an error detection, and an error concealment are performed. In addition, even if an error takes place, it is immediately prevented from propagating. Thus, it is not proper to discard non-error portion of the MPEG signal from a view point of high quality.
On the other hand, in an electronic watermark detecting device that detects an electronic watermark from an MPEG signal, it is not necessary to reproduce a moving picture and a sound in high quality. In addition, to detect an electronic watermark from an MPEG signal, it is not necessary to restore data of all DCT blocks of a frame. Even if several percent or several ten percent of all DCT blocks of a frame cannot be restored, an electronic watermark can be detected with the rest of the DCT blocks that have been restored. In an extreme case, when an electronic watermark cannot be detected with a predicted number of DCT blocks, the electronic watermark can be detected using the next frames.
According to the present invention, a non-error portion of the MPEG signal is also discarded to prevent an input of variable length codes from being interrupted on the assumption that an electronic watermark detecting device that detects an electronic watermark from an MPEG signal is used.
According to a first aspect of the present invention, there is provided a system for preventing an input of variable length codes from being interrupted, the system comprising: a variable length decoding device for decoding the variable length codes; a buffer for buffering the variable length codes to be supplied to the variable length decoding device; detecting means for detecting whether or not an occupation rate of the variable length codes in the buffer has increased; and discarding means for discarding the variable length codes to be supplied to the buffer when the occupation rate of the variable length codes in the buffer has increased.
In the system according to the first aspect, the system may deal with an MPEG (Motion Picture Experts Group) signal, and the system may further comprise: elementary stream extracting means, disposed between the buffer and the variable length decoding device, for extracting an elementary stream defined in MPEG standard.
In the system according to the first aspect, the system may deal with an MPEG (Motion Picture Experts Group) signal, and the system may further comprise: elementary stream extracting means, disposed upstream of the discarding means, for extracting an elementary stream defined in MPEG standard.
According to a second aspect of the present invention, there is provided a system for preventing an input of variable length codes from being interrupted, the system comprising: a variable length decoding device for decoding the variable length codes; a buffer for buffering the variable length codes to be supplied to the variable length decoding device; detecting means for detecting whether or not an occupation rate of the variable length codes in the buffer has increased; and skipping means for causing the variable length decoding device to skip the decoding operation when the occupation rate of the variable length codes in the buffer has increased.
In the system according to the second aspect, the skipping means may cause the variable length decoding device to skip the decoding operation until the variable length decoding device detects a predetermined code.
In the system according to the second aspect, the predetermined code may be a code at a refresh position of an original signal.
In the system according to the second aspect, the code at the refresh position of the original signal may be a byte aligned code.
In the system according to the second aspect, the system may deal with an MPEG (Motion Picture Experts Group) signal, and the system may further comprise: elementary stream extracting means, disposed upstream of the buffer, for extracting an elementary stream defined in MPEG standard.
According to a third aspect of the present invention, there is provided a system for preventing an input of variable length codes from being interrupted, the system comprising: a variable length decoding device for decoding the variable length codes; a buffer for buffering the variable length codes to be supplied to the variable length decoding device; code position detecting means for detecting whether or not a variable length code presently decoded by the variable length decoding device is of a position apart from a refresh position of an original signal by a predetermined distance; first occupation rate detecting means for detecting whether or not an occupation rate of the variable length codes in the buffer has increased when the detected result by the code position detecting means represents that the variable length code presently decoded by the variable length decoding device is of the position apart from the refresh position of the original signal by the predetermined distance; and skipping means for causing the variable length decoding device to skip the decoding operation when the detected result by the code position detecting means represents that the variable length code presently decoded by the variable length decoding device is of the position apart from the refresh position by the predetermined distance and the detected result by the first occupation rate detecting means represents that the occupation rate of the variable length codes in the buffer has increased.
In the system according to the third aspect, the skipping means may cause the variable length decoding device to skip the decoding operation until the variable length decoding device detects a predetermined code.
In the system according to the third aspect, the predetermined code may be a code at a refresh position of an original signal.
In the system according to the third aspect, the code at the refresh position of the original signal may be a byte aligned code.
The system according to the third aspect may further comprise: second occupation rate detecting means for detecting whether or not the occupation rate of the variable length codes in the buffer has increased regardless of whether or not the detected result by the code position detecting means represents that the variable length code presently decoded by the variable length decoding device is of the position apart from the refresh position of the original signal by the predetermine distance; and discarding means for discarding the variable length codes to be supplied to the buffer when the detected result by the second occupation rate detecting means represents that the occupation rate of the variable length codes in the buffer has increased.
In the system according to the third aspect, the system may deal with an MPEG (Motion Picture Experts Group) signal, and the system may further comprise: elementary stream extracting means, disposed upstream of the discarding means, for extracting an elementary stream defined in MPEG standard.
In the system according to the third aspect, the system may deal with an MPEG (Motion Picture Experts Group) signal, and the system may further comprise: elementary stream extracting means, disposed upstream of the buffer, for extracting an elementary stream defined in MPEG standard.
These and other objects, features and advantages of the present invention will become more apparent in light of the following detailed description of the best mode embodiment thereof, as illustrated in the accompanying drawings.